﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.Web.Mvc;
namespace VehicleManagement.Models
{
    //    -------------------车辆信息表---------------------
    //CREATE	TABLE CarInfo
    //(
    //CarID int  IDENTITY(1,1) primary key,
    //Car_num varchar(18) UNIQUE not null ,
    //Car_type varchar(18) not null,
    //Pic varchar(100) not null,
    //Car_available bit default(0) not null,
    //Car_state varchar(4) not null, --可用、出车、维修
    //Remark  varchar(100)
    //)

    /// <summary>
    /// 车辆信息类
    /// </summary>
    public class CarInfo
    {

        public int CarID { get; set; }

        [DisplayName("车牌号码")]
        [Required(ErrorMessage = "车牌号不能为空")]
        [StringLength(100, ErrorMessage = "车牌号不能超过18位")]
        [Remote("CheckCarNumberExists", "CarInfo", ErrorMessage = "该车辆已存在", AdditionalFields = "CarID")] // 远程验证
        public string CarNumber { get; set; }

        [DisplayName("车类型")]
        [Required(ErrorMessage = "车类型不能为空")]
        [StringLength(18, ErrorMessage = "类型不能超过18位")]
        public string CarType { get; set; }

        [DisplayName("车照片")]
        // [Required(ErrorMessage = "车照片不能为空")]
        public string Picture { get; set; }

        [DisplayName("车是否可用")]
        [Required(ErrorMessage = "是否可用不能为空")]
        public Boolean CarAvailable { get; set; }


        [DisplayName("车状态")]
        [Required(ErrorMessage = "车状态不能为空")]
        [StringLength(6, ErrorMessage = "状态不能超过4位")]
        public string CarState { get; set; }

        [DisplayName("说明")]
        [StringLength(100, ErrorMessage = "说明不能超过100位")]
        public string Remark { get; set; }


        public string CompanyName { get; set; }


        /// <summary>
        /// 获得车辆的状态
        /// </summary>
        /// <returns></returns>
        public List<SelectListItem> getCarState()
        {
            List<SelectListItem> P_Item = new List<SelectListItem>();

            //设置默认数据
            P_Item.Add(new SelectListItem() { Text = "空闲", Value = "空闲", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "出车", Value = "出车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "维修", Value = "维修", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "保养", Value = "保养", Selected = true });
            return P_Item;

        }

        /// <summary>
        /// 获取车辆类型
        /// </summary>
        /// <returns></returns>
        public List<SelectListItem> getCarType()
        {
            //创建新元素
            List<SelectListItem> P_Item = new List<SelectListItem>();
            //设置默认数据
            P_Item.Add(new SelectListItem() { Text = "大型客车", Value = "大型客车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "牵引车", Value = "牵引车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "城市公交车", Value = "城市公交车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "中型客车", Value = "中型客车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "小型汽车", Value = "小型汽车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "小型自动挡汽车", Value = "小型自动挡汽车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "低速载货汽车", Value = "低速载货汽车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "三轮汽车", Value = "三轮汽车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "普通三轮摩托车", Value = "普通三轮摩托车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "普通二轮摩托车", Value = "普通二轮摩托车", Selected = true }); P_Item.Add(new SelectListItem() { Text = "轻便摩托车", Value = "轻便摩托车", Selected = true });
            return P_Item;
        }
    }





    //public class CarInfoDBContext :DbContext
    //{
    //    public DbSet<CarInfo>  CarInfos
    //        {
    //        get;
    //        set;
    //        }
    //    }
}